package com.etc.homework;

import java.util.Objects;

/**
 * @author: knowno
 * @create: 2024-09-11 08:57
 * @Version 1.0
 * 6. 自定义一个员工类，员工编号，工资，岗位，姓名等，我们将员工的信息存储到HashSet中，
 * 业务规则，如果两个员工编号和姓名[或者自定义规则]都相同，我们认为他们是同一个员工，则只保留一个记录.
 **/
public class Employee {
    private  String empno;
    private String name;
    private String job;
    private double salary;


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Employee employee = (Employee) o;
        return Objects.equals(empno, employee.empno) && Objects.equals(name, employee.name);
    }

    @Override
    public int hashCode() {
        //Objects工具类，提供了一些静态方法
        return Objects.hash(empno, name);
    }

    @Override
    public String toString() {
        return "Employee{" +
                "empno='" + empno + '\'' +
                ", name='" + name + '\'' +
                ", job='" + job + '\'' +
                ", salary=" + salary +
                '}';
    }

    public Employee() {
    }

    public Employee(String empno, String name, String job, double salary) {
        this.empno = empno;
        this.name = name;
        this.job = job;
        this.salary = salary;
    }

    public String getEmpno() {
        return empno;
    }

    public void setEmpno(String empno) {
        this.empno = empno;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getJob() {
        return job;
    }

    public void setJob(String job) {
        this.job = job;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }
}
